const ShareListModel = require('../model').shareListModel;
const DaoTool = require('../lib/daoTool');
exports.createShare = function (conn, params) {
    return new Promise(function (resolve, reject) {
        let sql = "insert into share_list set ?";
        conn.query(sql, [DaoTool.generateModelObject(params, ShareListModel, 'create')], function (err, result) {
            printLog("=createShare=", this.sql);
            if (err) reject(err);
            resolve(result)
        });
    });
};
exports.queryShare = function (conn, params) {
    return new Promise(function (resolve, reject) {
        let sql = "select * from share_list where openid=?;";
        conn.query(sql, [params.openid], function (err, result) {
            printLog("=queryShare=", this.sql);
            if (err) reject(err);
            resolve(result)
        });
    });
};
exports.queryShareByShareId = function (conn, params) {
    return new Promise(function (resolve, reject) {
        let sql = "select * from share_list where ShareOpenId=?;";
        conn.query(sql, [params.ShareOpenId], function (err, result) {
            printLog("=queryShareByShareId=", this.sql);
            if (err) reject(err);
            resolve(result)
        });
    });
};
exports.deleteShare = function (conn, params) {
    return new Promise(function (resolve, reject) {
        let sql = "delete from share_list where openid=?;";
        conn.query(sql, [params.openid], function (err, result) {
            printLog("=deleteShare=", this.sql);
            if (err) reject(err);
            resolve(result)
        });
    });
};